import request from '@/utils/request'

export function delMenu(menu_id) {
  return request({
    url: '/menu/del',
    method: 'post',
    params: {
      rule_id: menu_id
    }
  })
}

// update Menu
export function updateMenu(menu) {
  return request({
    url: '/menu/update',
    method: 'post',
    params: {
      rule_id: menu.rule_id,
      pid: menu.pid,
      title: menu.title,
      route_path: menu.route_path,
      route_redirect: menu.route_redirect,
      route_name: menu.route_name,
      enabled: menu.enabled,
      is_menu: menu.is_menu,
      post_url: menu.post_url,
      icon: menu.icon
    }
  })
}

// update Menu
export function updateStatus(menu) {
  return request({
    url: '/menu/update',
    method: 'post',
    params: {
      menu_id: menu.menu_id,
      enabled: menu.enabled
    }
  })
}

// create Menu
export function createMenu(menu) {
  return request({
    url: '/menu/create',
    method: 'post',
    params: {
      pid: menu.pid,
      title: menu.title,
      route_path: menu.route_path,
      route_redirect: menu.route_redirect,
      route_name: menu.route_name,
      enabled: menu.enabled,
      is_menu: menu.is_menu,
      post_url: menu.post_url,
      icon: menu.icon
    }
  })
}

